package com.wing.product.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wing.common.annotation.RequestObjectFieldIgnore;
import com.wing.common.utils.JsonResult;
import com.wing.common.utils.PageResult;
import com.wing.product.model.entity.WarehouseShipmentOrder;
import com.wing.product.model.entity.WarehouseShipmentOrderDetail;
import com.wing.product.model.response.WarehouseShipmentOrderVO;
import com.wing.product.service.WarehouseProductInventoryService;
import com.wing.product.service.WarehouseShipmentOrderDetailService;
import com.wing.product.service.WarehouseShipmentOrderDetailServiceImpl;
import com.wing.product.service.WarehouseShipmentOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;

import java.util.HashMap;
import java.util.Map;

/**
* 发货单详情(warehouse_shipment_order_detail)表控制层
*
* @author xxxxx
*/
@Api(value = "发货记录", tags = "#/warehouse/product/shipmentOrderDetail")
@RestController("WarehouseShipmentOrderDetailController")
@RequestMapping("/warehouse/shipmentOrderDetail")
@RequiredArgsConstructor
public class WarehouseShipmentOrderDetailController {
/**
* 服务对象
*/
    @Autowired
    private WarehouseShipmentOrderDetailService warehouseShipmentOrderDetailService;


    @Autowired
    private WarehouseShipmentOrderService warehouseShipmentOrderService;

    @Autowired
    private WarehouseProductInventoryService warehouseProductInventoryService;

    @ApiOperation(value = "详情", notes = "详情")
    @RequestObjectFieldIgnore({"id"})
    @GetMapping("/info")
    public JsonResult info(String id ) {
        return JsonResult.success(warehouseProductInventoryService.findByShipmentOrderDetailId(id));
    }

    @ApiOperation(value = "查询列表", notes = "搜索")
    @GetMapping("/list")
    public PageResult<WarehouseShipmentOrderVO> list(
            @RequestParam(value = "page", defaultValue = "1", required = false) Integer page
            ,@RequestParam(value = "limit", defaultValue = "10", required = false) Integer limit
            ,@RequestParam(value = "sort", defaultValue = "create_time", required = false) String sort
            ,@RequestParam(value = "order", defaultValue = "asc", required = false) String order,
            String status,
            String shipOrder,
            String customerName,
            String contactName,
            String waybill,
            String plateNo,
            String sTime,
            String eTime,
            String userBundleCode
    ){


        Page<WarehouseShipmentOrder> pg = new Page<>(page, limit);
        Map paramMap=new HashMap();
//        paramMap.put("warehouseCustomerId",warehouseCustomerId);
        paramMap.put("status",status);//状态
        paramMap.put("shipOrder",shipOrder);//发货单号
        paramMap.put("customerName",customerName);//客户
        paramMap.put("contactName",contactName);//联系人
        paramMap.put("waybill",waybill);//运单号
        paramMap.put("plateNo",plateNo);//车牌号
        paramMap.put("sTime",sTime);//开始时间
        paramMap.put("eTime",eTime);//结束时间
        paramMap.put("userBundleCode",userBundleCode);//结束时间

//        return warehouseShipmentOrderService.pageList4app(pg,paramMap);
        IPage<WarehouseShipmentOrderVO> list = warehouseShipmentOrderDetailService.pageList4app(pg,paramMap);
        return new PageResult<>(list.getRecords(), list.getTotal());
    }


}
